﻿﻿

<!--********************* Part1:Jsp Head *********************-->

<%@page import="com.hitrust.gs.util.date.DateUtil"%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/framework/head.jsp"%>
<%@ page import="com.hitrust.gs.lib.GSAutoAuditongDateConfigurator"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.ArrayList"%>

<!--********************* Part2:Java Code *********************-->
<%
	ProductTemporaryMaintainSearchEvent event = (ProductTemporaryMaintainSearchEvent) context
				.getSessionValue("ProductTemporaryMaintainSearchEvent");
	ObjectList list = ProductTemporaryMaintain.fetch().search(con, event);
	String showType = (String)request.getAttribute("showType"); 
	if(showType==null){
		showType=request.getParameter("showType"); 
	}
		String starttime = (String) request.getParameter("i_EnabledTimeStart");
%>
<%@ page import="com.hitrust.gs.service.*"%>
<!--********************* Part3:JavaScript Code ***************-->
<!--start 客户端脚本区域-->
<%@page import="system.LoginContext"%>


<script language=javascript>
var list_code = "listProductTemporaryMaintain";
function doSearch()
{
    SetValue("s_ConcentricityCode",GetValue("i_ConcentricityCode")); //替换产品集中编码
    SetValue("s_TemporaryConcentricityCode",GetValue("i_TemporaryConcentricityCode")); //被替换产品集中编码 
    SetValue("s_ProductName",GetValue("i_ProductName")); //替换产品名称
    SetValue("s_TemporaryProductName",GetValue("i_TemporaryProductName")); //被替换产品名称
    SetValue("s_Spec",GetValue("i_Spec")); //替换产品规格
    SetValue("s_TemporarySpec",GetValue("i_TemporarySpec")); //被替换产品规格
    SetValue("s_Model",GetValue("i_Model")); //替换产品型号
    SetValue("s_TemporaryModel",GetValue("i_TemporaryModel")); //被替换产品型号
    SetValue("s_DrawingPieceCode",GetValue("i_DrawingPieceCode")); //替换产品图件号
    SetValue("s_TemporaryDrawingPieceCode",GetValue("i_TemporaryDrawingPieceCode")); //被替换产品图件号
    SetValue("s_ProviderCode",GetValue("i_ProviderCode")); //供应商
    SetValue("s_Status",GetValue("i_Status")); //是否执行
    SetValue("s_AuditingStatus",GetValue("i_AuditingStatus")); //状态
    SetValue("s_EnabledTimeStart",GetValue("i_EnabledTimeStart")); //启用日期(开始)
    SetValue("s_EnabledTimeEnd",GetValue("i_EnabledTimeEnd")); //启用日期(结束)
    SetValue("s_ShowType",<%=showType%>);//
    SetValue("s_IsFirst","false");//
    doCommonSearch();
}

function doExcel(){
    <%if (list.getTotalSize() > 20000) {%>
        alert("导出EXCEL产品数量不能超过20000条！");
        return false;
    <%} else {%>
        window.location.href="<%=Config.getWebPath()%>/GSproductTemporaryMaintainDown";
    <%}%>
}

function pass(){
var indexs = document.getElementsByName("ids");
			var isSelected = false;
			var ids='';
			for(i=0;i<indexs.length;i++){
				if(indexs[i].checked ){
					isSelected = true;
					var str=indexs[i].value.split(',');
					ids+=str[0]+',';
					if(str[1]!='0'){
						alert("存在审批状态不是待审批的记录!");
						return false;
					}
				
				var time=Trim(str[2]);
                    var timeStr = time.substring(0,4)+time.substring(5,7)+time.substring(8,10);
                    var hourStr = time.substring(11,13);
                    var minuteStr = time.substring(14,16);
                    if(parseInt(hourStr)==0){
           				hourStr=hourStr.substring(1,hourStr.length);
           			}
           			if(parseInt(minuteStr)==0){
           				minuteStr=minuteStr.substring(1,minuteStr.length);
           			}
                    
                    if(parseInt(timeStr)<<%=Long.parseLong(DateUtil.getCurrentDate("yyyyMMdd"))%>){
                    	 alert("存在启用日期已过期的记录,过期的记录只能设置为审批不通过!");
                         return false;
                    }
                    
                    if(parseInt(timeStr)==<%=Long.parseLong(DateUtil.getCurrentDate("yyyyMMdd"))%>
                     && parseInt(hourStr)<<%=Long.parseLong(DateUtil.getCurrentDate("HH"))%>){
                    	 alert("存在启用日期已过期的记录,过期的记录只能设置为审批不通过!");
                         return false;
                    }
                    
                    if(parseInt(timeStr)==<%=Long.parseLong(DateUtil.getCurrentDate("yyyyMMdd"))%>
                     && parseInt(hourStr)==<%=Long.parseLong(DateUtil.getCurrentDate("HH"))%>
                     && parseInt(minuteStr)<=<%=Long.parseLong(DateUtil.getCurrentDate("mm"))%>){
                    	 alert("存在启用日期已过期的记录,过期的记录只能设置为审批不通过!");
                         return false;
                    }
				}
			}
			
			ids=ids.substring(0,ids.length-1);
			
			if(isSelected != true) {
				alert("请至少选择一条记录");
				return false;
			}

			if(confirm("是否确定审批通过？")){						
				document.pager.action = "/gw/A190020.do";
				document.all.confirmorreject.value='T';
				document.all.indexs.value=ids;
                document.pager.method="post";			
				document.pager.submit();
			}else{
				return false;
			}
}

function unpass(){
var indexs = document.getElementsByName("ids");
			var ids='';
			var isSelected = false;
			for(i=0;i<indexs.length;i++){
				if(indexs[i].checked ){
					isSelected = true;
					var str=indexs[i].value.split(',');
					ids+=str[0]+',';
					if(str[1]!='0'){
						alert("存在审批状态不是待审批的记录!");
						return false;
					}
				}
			}
			if(isSelected != true) {
				alert("请至少选择一条记录");
				return false;
			}

			if(confirm("是否确定审批不通过？")){						
				document.pager.action = "/gw/A190020.do";
				document.all.confirmorreject.value='F';
				document.all.indexs.value=ids;
                document.pager.method="post";			
				document.pager.submit();
			}else{
				return false;
			}
}




function addInfos()
{
  window.open("<%= response.encodeURL(request.getContextPath() + "/A190015.do")%>");
}


key_InitDefault();
key_RegSubmitHandler(doSearch);


</script>
<%=uiBody%>>

<%@ include file="/framework/menu.jsp"%>

<!--********************* Part4:Form  ***************-->
<form id=frm name='pager' action="<%=Config.getSrv()%>" method="post">
<input type="hidden" name='indexs'>
<input type="hidden" name='confirmorreject'>
<input type=hidden name="action_code" value=""> <input type=hidden
	name="Id" value=""> <input type=hidden name=sortOrder value="">
 <input type=hidden name="s_ConcentricityCode"
	value="<%=event.getConcentricityCode()%>"> <!--替换集中编码--> 
 <input type=hidden name="s_TemporaryConcentricityCode"
	value="<%=event.getTemporaryConcentricityCode()%>"> <!--被替换集中编码-->
 <input type=hidden name="s_ProductName"
	value="<%=event.getProductName()%>"> <!--替换产品名称--> 
 <input type=hidden name="s_TemporaryProductName"
	value="<%=event.getTemporaryProductName()%>"> <!--被替换产品名称-->
	
<input type=hidden name="s_Spec" value="<%=event.getSpec()%>"> <!--替换产品规格-->
<input type=hidden name="s_TemporarySpec" value="<%=event.getTemporarySpec()%>"> <!--被替换产品规格-->

<input type=hidden name="s_Model" value="<%=event.getModel()%>"> <!--替换产品型号--> 
<input type=hidden name="s_TemporaryModel" value="<%=event.getTemporaryModel()%>"> <!--被替换产品型号-->
<input type=hidden name="s_DrawingPieceCode" value="<%=event.getDrawingPieceCode()%>"> <!--替换产品图件号--> 
<input type=hidden name="s_TemporaryDrawingPieceCode" value="<%=event.getTemporaryDrawingPieceCode()%>"> <!--被替换产品图件号--> 
 
 <input type=hidden name="s_ProviderCode"
	value="<%=event.getProviderCode()%>"><!--供应商--> 
<input type=hidden name="s_Status"
	value="<%=event.getStatus()%>"> <!--是否执行-->
<input type=hidden name="s_AuditingStatus"
	value="<%=event.getAuditingStatus()%>"> <!--状态-->  
<input type=hidden name="s_EnabledTimeStart"
	value="<%=event.getEnabledTimeStart()%>"> <!--启用日期(开始)-->  
<input type=hidden name="s_EnabledTimeEnd"
	value="<%=event.getEnabledTimeEnd()%>"> <!--启用日期(结束)-->  
	<input type=hidden name="s_ShowType"
	value="<%=event.getShowtype()%>"> <!--权限控制-->  
	<input type=hidden name="s_IsFirst"
	value="true"> <!--权限控制-->  
	

<%@ include file="/framework/list_head.jsp"%> <br>
<!--********************* Part5:Search Area ***************--> <%=uiSearchStart%>>
<%
 	int key_tab = 1;
 %> <%=uiSearchInputTR%>> <%=uiSearchInputTR%>> <%=uiSearchInputTDHead%>>
启用日期：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     
 <%=framework.custom.UIManager.generateDateInput("i_EnabledTimeStart",event.getEnabledTimeStart().equals("")&&starttime==null?DateUtil.getCurrentDate("yyyy-MM-dd"):event.getEnabledTimeStart())%>
    ～<%=framework.custom.UIManager.generateDateInput("i_EnabledTimeEnd", event.getEnabledTimeEnd())%>
</td>
</tr>
 <%=uiSearchInputTR%>><%=uiSearchInputTDHead%>> 替换产品编码：&nbsp;&nbsp; <input type="text"
	class="texts" name="i_ConcentricityCode" size="20"
	value="<%=event.viewConcentricityCode()%>" key_tab="<%=key_tab++%>">
&nbsp;&nbsp;&nbsp;&nbsp;被替换产品编码：&nbsp;&nbsp;&nbsp;&nbsp; <input type="text"
	class="texts" name="i_TemporaryConcentricityCode" size="20" value="<%=event.viewTemporaryConcentricityCode()%>"
	key_tab="<%=key_tab++%>">
</td>
</tr>

 <%=uiSearchInputTR%>><%=uiSearchInputTDHead%>> 替换产品名称：&nbsp;&nbsp; <input type="text"
	class="texts" name="i_ProductName" size="20"
	value="<%=event.viewProductName()%>" key_tab="<%=key_tab++%>">
&nbsp;&nbsp;&nbsp;&nbsp;被替换产品名称：&nbsp;&nbsp;&nbsp;&nbsp; <input type="text"
	class="texts" name="i_TemporaryProductName" size="20" value="<%=event.viewTemporaryProductName()%>"
	key_tab="<%=key_tab++%>">
</td>
</tr>

 <%=uiSearchInputTR%>><%=uiSearchInputTDHead%>> 替换产品规格：&nbsp;&nbsp; <input type="text"
	class="texts" name="i_Spec" size="20"
	value="<%=event.viewSpec()%>" key_tab="<%=key_tab++%>">
&nbsp;&nbsp;&nbsp;&nbsp;被替换产品规格：&nbsp;&nbsp;&nbsp;&nbsp; <input type="text"
	class="texts" name="i_TemporarySpec" size="20" value="<%=event.viewTemporarySpec()%>"
	key_tab="<%=key_tab++%>">
</td>
</tr>


 <%=uiSearchInputTR%>><%=uiSearchInputTDHead%>> 替换产品型号：&nbsp;&nbsp; <input type="text"
	class="texts" name="i_Model" size="20"
	value="<%=event.viewModel()%>" key_tab="<%=key_tab++%>">
&nbsp;&nbsp;&nbsp;&nbsp;被替换产品型号：&nbsp;&nbsp;&nbsp;&nbsp; <input type="text"
	class="texts" name="i_TemporaryModel" size="20" value="<%=event.viewTemporaryModel()%>"
	key_tab="<%=key_tab++%>">
</td>
</tr>

 <%=uiSearchInputTR%>><%=uiSearchInputTDHead%>> 替换产品图件号： <input type="text"
	class="texts" name="i_DrawingPieceCode" size="20"
	value="<%=event.viewDrawingPieceCode()%>" key_tab="<%=key_tab++%>">
&nbsp;&nbsp;&nbsp;&nbsp;被替换产品图件号：&nbsp;&nbsp; <input type="text"
	class="texts" name="i_TemporaryDrawingPieceCode" size="20" value="<%=event.viewTemporaryDrawingPieceCode()%>"
	key_tab="<%=key_tab++%>">
</td>
</tr>


<%=uiSearchInputTR%>> <%=uiSearchInputTDHead%>>
&nbsp;&nbsp;&nbsp;&nbsp;供&nbsp;应&nbsp;商：&nbsp;&nbsp; <input
	type="text" class="texts" name="i_ProviderCode" size="20"
	value="<%=event.getProviderCode() %>" key_tab="<%=key_tab++%>">
 
 &nbsp;&nbsp;&nbsp;&nbsp;是否执行：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	 <select name="i_Status">
			<option value="">---全部---</option>
				<%
			ArrayList statusList = (ArrayList) request.getAttribute("statusList");
			String status = request.getParameter("i_Status");
			if (statusList != null && statusList.size() > 0) {
				for (int i = 0; i < statusList.size(); i++) {
				String[] temp = (String[]) statusList.get(i);
				if (status != null && status.equals(temp[0])) {
					%>
			<option value="<%=temp[0]%>" selected><%=temp[1]%></option>
			<%} else {
					%>
			<option value="<%=temp[0]%>"><%=temp[1]%></option>
			<%
				}
			}
		}

		%>
		</select>
		<%if("0".equals(showType)){ %>
	&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="查询" class="buttons"
	onclick="doSearch();return false;"><input type="button"
	value="清空" class="buttons" onclick="doClearEvent();return false;">
		<%} %>
		
</td>
</tr>
 <%=uiSearchInputTR%>><%=uiSearchInputTDHead%>>
<%if("0".equals(showType)){ %>
<input type="hidden" name="i_AuditingStatus" value="1" />
<%}else{ %>
&nbsp;&nbsp;&nbsp;&nbsp;状&nbsp;&nbsp;&nbsp;&nbsp;态：&nbsp;&nbsp;
 <select name="i_AuditingStatus">
		<option value="">---全部---</option>
			<%
		ArrayList auditingStatusList = (ArrayList) request.getAttribute("auditingStatusList");
		String auditingStatus = request.getParameter("i_AuditingStatus");
		if (auditingStatusList != null && auditingStatusList.size() > 0) {
			for (int i = 0; i < auditingStatusList.size(); i++) {
				String[] temp = (String[]) auditingStatusList.get(i);
				if (auditingStatus != null && auditingStatus.equals(temp[0])) {
					%>
			<option value="<%=temp[0]%>" selected><%=temp[1]%></option>
			<%} else {
					%>
			<option value="<%=temp[0]%>"><%=temp[1]%></option>
			<%
				}
			}
		}

		%>
		</select>
		
	<%}%>
 	<%if(!"0".equals(showType)){ %>
	&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="查询" class="buttons"
	onclick="doSearch();return false;"><input type="button"
	value="清空" class="buttons" onclick="doClearEvent();return false;">
	<%} %>
</td>
</tr>


<%=uiSearchEnd%> <!--列表标题--> <%=UIManager.addListHeadTitle("产品替换列表")%> <!--********************* Part6:List Area ***************-->

<%=uiListStart%>> <%@ include file="/framework/list_foot.jsp"%>

<%
	int index = 1;
%> <%=uiListHeadTR%>> 
<%=UIManager.addListHeadCheckBox()%> 
<%=UIManager.addListHead("替换集中编码", index++)%>
<%=UIManager.addListHead("替换产品名称", index++)%> 
<%=UIManager.addListHead("被替换集中编码", index++)%>
<%=UIManager.addListHead("被替换产品名称", index++)%> 
<%=UIManager.addListHead("启用日期", index++)%>
<%=UIManager.addListHead("是否启用", index++)%>
<%=UIManager.addListHead("审批状态", index++)%>
<%=UIManager.addListHead("创建人", index++)%>
<%=UIManager.addListHead("创建时间", index++)%>
<%=UIManager.addListHead("审批人", index++)%>
<%=UIManager.addListHead("审批时间", index++)%>

<%=uiListHeadTREnd%>> <!--data-->


 <%
 	for (int i = 0; i < list.size(); i++) {
 			ProductTemporaryMaintain obj = (ProductTemporaryMaintain) list.get(i);
 %> <%=uiListDataTR[i % 2]%> align=center> 

  <%=uiListDataTD%>> 
 <input
	type="checkbox" name="ids" value="<%=obj.getId()+","+obj.getAuditingStatus()+","+obj.getEnabledTime()%>">
</td>

<%=uiListDataTD%>><%=obj.viewConcentricityCode(con)%></td>
<%
	Product cmd = Product.fetch(con,
					obj.getProductId());
					
	Product temporaryProduct = Product.fetch(con,
					obj.getTemporaryProductId());
%>
<%=uiListDataTD%>><%=cmd.viewName(con)%></td>
<%=uiListDataTD%>><%=obj.viewTemporaryConcentricityCode(con)%></td>
<%=uiListDataTD%>><%=temporaryProduct.viewName(con)%></td>
<%=uiListDataTD%>><%=obj.viewEnabledTime(con)%></td>
<%=uiListDataTD%>><%=GSBaseManager.getStatusName(obj.getStatus())%></td>
<%=uiListDataTD%>><%=GSBaseManager.getAuditingStatusName(obj.viewAuditingStatus(con))%></td>
<%=uiListDataTD%>><%=obj.viewCreateUser(con)%></td>
<%=uiListDataTD%>><%=obj.viewCreateTime(con)%></td>
<%=uiListDataTD%>><%=obj.viewAuditingUser(con)%></td>
<%=uiListDataTD%>><%=obj.viewAuditingTime(con)%></td>
</tr>
<%
	}
%> <%@ include file="/framework/list_foot2.jsp"%>

<%=uiListEnd%> <!--********************* Part7:Action Area ***************-->
<%=uiCommandStart%>> <%=uiCommandTR%>> <%=uiCommandTD%>>


<%if("1".equals(showType)){ %>
<input type=button value="　　批量导入　　" class="buttons"
	onclick="addInfos();">
	<%} %>
<%if("2".equals(showType)){ %>
<input type=button value="　　设置审批通过　　" class="buttons"
	onclick="pass();">
	<%} %>
<%if("2".equals(showType)){ %>
<input type=button value="　　设置审批不通过 　" class="buttons"
	onclick="unpass();">
	<%} %>
<input type=button value="　　导出EXCEL　　" class="buttons"
	onclick="doExcel();return false;">
</td>
</tr>
<%=uiCommandEnd%></form>
<script language=javascript>

</script>
<%@ include file="/framework/foot.jsp"%>

<!--
    Author    :chengbiao.he
    FileName  :/system/base/ProductList.jsp
-->
